package controllerLayer;

import java.io.IOException;
import java.util.ArrayList;



import modelLayer.LeaseProductsRecords;

import modelLayer.Loan;
import modelLayer.LoanRecords;
import modelLayer.ProductForLease;


public class LoanCtr {
	
	private LeaseProductsRecords lpr;
	private LoanRecords lrec;

	public LoanCtr(){
		
		lpr = LeaseProductsRecords.getInstance();
		lrec = LoanRecords.getInstance();

	}
	public ArrayList<Loan> getLoans(){
		return lrec.getLoans();
	}
	
	public void addLItem(ProductForLease product)
	{
		lpr.addLItem(product);
	}
	public int createLItem(String name, String description, double price, double quantity, String category, String state)
	{
		int id = lpr.createLItem(name, description, price, quantity, category, state);
		return id;
	}
	public ProductForLease getProduct(int id){
		return lpr.getProduct(id);
		
	}
	public String findLProduct(int id){
		return lpr.findLProduct(id);
	}
	public void updateLProduct(int id, double quantity, double price){
		lpr.updateLProduct(id, quantity, price);
	}
	
	public void deleteProduct(int id){
		lpr.deleteProduct(id);
	}
	
	
	
	public void loanProduct(String idCust, int idProd, String idEmp, String borrowDate, int period ){
		lrec.loanProduct(idCust, idProd, idEmp, borrowDate, period);
	}
	
	public void returnProduct(int idProd)
	{
		lrec.returnProduct(idProd);
	}
	public void save() throws IOException{
		lrec.save();
		lpr.save();
	}
	
}
